// 导入必要的函数和组件
import { createRouter, createWebHashHistory } from 'vue-router';

// 定义路由规则
const routes = [
    {
        path: '/',
        name: 'main',
        component: () => import("@/views/Main.vue"),
        redirect: "/home",
        children: [
            {
                path: '/home',
                name: 'home',
                component: () => import("@/views/Home.vue"),
                meta: { keepAlive: true }
            },
            {
                path: '/storeCashier',
                name: 'storeCashier',
                component: () => import("@/views/StoreCashier.vue"),
                meta: { keepAlive: true }
            },
            {
                path: '/Settlement',
                name: 'Settlement',
                component: () => import("@/views/Settlement.vue"),
                meta: { keepAlive: true }
            },
            {
                path: '/inventory',
                name: 'inventory',
                component: () => import("@/views/Inventory.vue"),
                meta: { keepAlive: true }
            },
            {
                path: '/InventoryTransaction',
                name: 'InventoryTransaction',
                component: () => import("@/views/InventoryTransaction.vue"),
                meta: { keepAlive: true }
            },
            {
                path: '/InventoryTransactionDocuments',
                name: 'InventoryTransactionDocuments',
                component: () => import("@/views/InventoryTransactionDocuments.vue"),
                meta: { keepAlive: true }
            }
        ],
    },
    {
        path: '/login',
        name: 'login',
        component: () => import("@/views/login.vue"),
    },
    {
        path: '/404',
        name: '404',
        component: () => import('@/views/404.vue')
    }
];

// 创建路由实例，并传入路由规则和历史记录模式
const router = createRouter({
    history: createWebHashHistory(), // 使用内存历史记录模式（通常用于客户端路由）
    routes, // 传入路由规则
});

// 导出路由实例，以便在Vue应用中使用
export default router;